using Common;
using TMPro;
using UnityEngine;

namespace CardGameObject.GameScene
{
    public class GameMana : MonoBehaviour
    {
        public PlayerRoleEnum PlayerRole;
        public TextMeshPro ManaText;

        public int Mana { get; set; } = 0;
        public int CurMana { get; set; } = 0;

        public void IncreaseManaWhenTurnStart()
        {
            Mana = Mana == 10 ? 10 : Mana + 1;
            CurMana = Mana;
            UpdateManaText();
        }

        public void IncreaseMana(int value)
        {
            Mana += value;
            UpdateManaText();
        }

        public void IncreaseCurMana(int value)
        {
            CurMana = CurMana + value > Mana ? Mana : CurMana + value;
            UpdateManaText();
        }

        public bool CostMana(int value)
        {
            if (value > CurMana)
            {
                Debug.Log("���ò������ٻ�");
                return false;
            }
            CurMana -= value;
            UpdateManaText();
            return true;
        }

        public void UpdateManaText()
        {
            ManaText.text = CurMana+"/"+Mana;
        }
    }
}